# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: TBK <alpine@jjtc.eu>
pkgname=libimagequant
pkgver=4.2.2
pkgrel=0
pkgdesc="Rust library for high-quality conversion of RGBA images to 8-bit indexed-color (palette) images"
url="https://pngquant.org/lib/"
arch="all"
license="GPL-3.0-or-later"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="cargo cargo-auditable cargo-c"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/ImageOptim/libimagequant/archive/$pkgver.tar.gz
	Cargo.lock
	"
builddir="$srcdir/$pkgname-$pkgver/imagequant-sys"
options="net"

case "$CARCH" in
x86)
	# tests fail
	options="$options !check"
	;;
*)
	;;
esac

prepare() {
	default_prepare

	ln -sfv "$srcdir"/Cargo.lock ../Cargo.lock

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable cbuild --release \
		--frozen \
		--prefix /usr \
		--library-type cdylib
}

check() {
	cargo test --frozen
}

package() {
	cargo auditable cinstall --release \
		--frozen \
		--prefix /usr \
		--destdir "$pkgdir" \
		--library-type cdylib
}

sha512sums="
31bd79024abc1fd884461f8f422d6eac1f5786ce347ac3c517e9cb66f289ad1ace0e3a25c55c7b7384badb2545174871464d60f1238ed2deb1f521d5f3ede96b  libimagequant-4.2.2.tar.gz
f93efe8408e706cb710457899e2b163f6714b3079a092756cebf2a48f1bc15a4458f9c36021bb682726909efa4d41f3f69c400b6ff548844e12171b7eb911325  Cargo.lock
"
